﻿<%@ Page Title="Vật tư" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="KhoiLuongVatTuNew.aspx.cs" Inherits="QuanLyHopDong.Web.HopDong.KhoiLuongVatTuNew" %>

<%@ Import Namespace="Resources" %>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Nhập vật tư</h2>
    <p></p>
    <span class="failureNotification">
        <asp:Literal ID="lblErrorMessage" runat="server"></asp:Literal></span>
    <div>
        <table>
            <tr>
                <td>
                    <b>Số HĐ:</b>
                    <asp:Literal ID="ltrSoHopDong" runat="server"></asp:Literal>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Đơn vị ký HĐ:</b>
                    <asp:Literal ID="ltrTenDonVi" runat="server"></asp:Literal>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Loại dự án:</b>
                    <asp:Literal ID="ltrLoaiDuAn" runat="server"></asp:Literal>
                </td>
            </tr>
        </table>
    </div>
    <table>
        <tr>
            <td style="vertical-align: top;">
                <div style="margin-right: 50px; vertical-align: top;">
                    <p>
                        <label>Mã tuyến</label>
                        <asp:DropDownList ID="ddlMaTuyen" runat="server"></asp:DropDownList>
                    </p>
                    <p>
                        <label>Phiếu xuất</label>
                        <asp:DropDownList ID="ddlPhieuXuat" runat="server"></asp:DropDownList>
                    </p>
                    <p>
                        <label>Vật tư:</label>
                        <asp:TextBox ID="txtVatTu" runat="server" CssClass="textEntry name validate[required]"></asp:TextBox>
                    </p>
                    <p>
                        <label>Số lượng theo hợp đồng:</label>
                        <asp:TextBox ID="txtSoLuong" runat="server" CssClass="textEntry sortorder"></asp:TextBox>
                    </p>
                    <p>
                        <label>Đơn vị tính</label>
                        <asp:DropDownList ID="ddlDonViTinh" runat="server">
                            <asp:ListItem Value="1">m</asp:ListItem>
                            <asp:ListItem Value="2">km</asp:ListItem>
                            <asp:ListItem Value="3">cái</asp:ListItem>
                            <asp:ListItem Value="4">bộ</asp:ListItem>
                        </asp:DropDownList>
                    </p>
                    <p>
                        <label>Bên cấp:</label>
                        <asp:DropDownList ID="ddlBenCap" runat="server">
                            <asp:ListItem Value="1">A cấp</asp:ListItem>
                            <asp:ListItem Value="2">B cấp</asp:ListItem>
                        </asp:DropDownList>
                    </p>
                </div>
            </td>
            <td style="vertical-align: top;">
                <div style="vertical-align: top;">
                    <p>
                        <label>Cập nhật vật tư theo phiếu xuất kho:</label>
                        <asp:TextBox ID="txtThiCong" runat="server" CssClass="textEntry sortorder"></asp:TextBox>
                    </p>
                   <%-- <p>
                        <label>Phiếu xuất kho:</label>
                        <asp:FileUpload ID="filePhieuXuatKho" runat="server" />
                    </p>--%>
                    <p>
                        <label>Cập nhật vật tư thực tế thi công:</label>
                        <asp:TextBox ID="txtThucTe" runat="server" CssClass="textEntry sortorder"></asp:TextBox>
                    </p>
                    <%--<p>
                        <label>Khối lượng vật tư thi công sơ bộ:</label>
                        <asp:FileUpload ID="fileBienBanBanGiao" runat="server" />
                    </p>--%>
                    <p>
                        <label>Ghi chú:</label>
                        <asp:TextBox ID="txtGhiChu" runat="server" TextMode="MultiLine" CssClass="textEntry description"></asp:TextBox>
                    </p>
                </div>
            </td>
        </tr>
    </table>

    <p>
        <asp:Button ID="btnSave" runat="server" Text="<%$ Resources:GlobalStrings, Save %>"
            CssClass="submitButton" OnClick="btnSave_Click" />
        <input id="btnCancel" type="button" value="<%=GlobalStrings.Cancel %>"
            class="submitButton" onclick="Cancel()" />
    </p>

    <script type="text/javascript">
        $(function () {
            $(window.theForm).validationEngine();
            
            $("#<%=txtVatTu.ClientID %>").autocomplete({
                source: function (request, response) {
                    $.ajax({
                        url: "/DanhMuc/VatTu/Default.aspx/SearchVatTus",
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify({
                            term: extractLast(request.term)
                        }),
                        success: function (data) {
                            response($.map(data.d, function (item) {
                                return {
                                    label: item.value,
                                    value: item.value
                                };
                            }));
                        }
                    });
                }
            });
        });
        
        function split(val) {
            return val.split(/,\s*/);
        }

        function extractLast(term) {
            return split(term).pop();
        }

        function Cancel() {
            window.location = 'KhoiLuong.aspx?hopDongId=<%=Request.Params["hopDongId"] %>#tabs-3';
        }
    </script>
</asp:Content>
